package com.sky.mapper;


import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {




    //查询购物车
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    //更改购物车数量
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void updateNumber(ShoppingCart shoppingCart);


    //添加购物车
    @Insert("insert into shopping_cart (name, image, dish_flavor, number, amount, dish_id, setmeal_id, create_time, user_id) " +
            "values (#{name}, #{image}, #{dishFlavor}, #{number}, #{amount}, #{dishId}, #{setmealId}, #{createTime}, #{userId})")
    void insert(ShoppingCart cart);

    //清空购物车
    @Update("delete from shopping_cart where user_id = #{userId}")
    void deleteByUserId(Long userId);

    //删除购物车商品
    void delete(ShoppingCart cart);

    //批量插入购物车数据
     void insertBatch(List<ShoppingCart> collects);

}
